import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] age = new int[3];
        for (int i = 0; i < age.length; i++) {
            age[i] = sc.nextInt();
        }
        int count = 0;
        while (count <= 100) {
            for (int i = 0; i < age.length; i++) {
                age[i] += 1;
            }
            count++;
            if ((age[0] % 10 == 3 && age[1] % 10 == 6 && age[2] % 10 == 9)
                    || (age[0] % 10 == 3 && age[1] % 10 == 9 && age[2] % 10 == 6)
                    || (age[0] % 10 == 6 && age[1] % 10 == 3 && age[2] % 10 == 9)
                    || (age[0] % 10 == 6 && age[1] % 10 == 9 && age[2] % 10 == 3)
                    || (age[0] % 10 == 9 && age[1] % 10 == 6 && age[2] % 10 == 3)
                    || (age[0] % 10 == 9 && age[1] % 10 == 3 && age[2] % 10 == 6)) {
                break;
            }
        }
        if (count > 100)
            System.out.println("so sad!");
        else
            System.out.println(count);
    }
}
